

//////////////////////////////////////////////////////////////////////////////
// Filename:	hcpsundries.h
// Description:	This file provides structures and related enums used by the
//				interface.	
// Copyright:	Varian Medical Systems
//				All Rights Reserved
//				Varian Proprietary   
//////////////////////////////////////////////////////////////////////////////

#ifndef VIP_INC_SUNDRYSTRUCTS_H
#define VIP_INC_SUNDRYSTRUCTS_H

#ifndef MAX_STR
#define MAX_STR		256
#endif

#ifndef MIN_STR
#define MIN_STR		32
#endif

#define		HCP_DBG_OFF		0
#define		HCP_DBG_ON		1
#define		HCP_DBG_ON_FLSH	2
#define		HCP_DBG_ON_DLG	3

#define		CLSLNK_RELMEM			0x0200
			// Use to signal that buffer memory should be deleted.

//////////////////////////////////////////////////////////////////////////////
struct SCallStatus
{
	int				StructSize;		// Initialize to sizeof(SCallStatus)
	SCallStatus*	LinkedCS;		// pointer to a CallStatus structure 
					// (to allow a linked list if required.) Initialize to NULL
	int				ErrorCode;		// initialize to VIP_NO_ERR
	int				State;			// initialize to IDLE
	int				Timeout;		// initialize to 5000 (ms) 
					// (Implementation not planned initially)
	void*			SetStatePtr;	// function pointer to the 'SetState' function 
					// - initialize to the address of the SetState function.
	void*			GetFuncPtr;		// function pointer to the 'GetFunc' function 
					// - initialize to the address of the GetFunc function.
	char			ErrorMsg[MAX_STR];	// (char[256] - initialize to "")
	char			ActionStr[MAX_STR];	// (char[256] - initialize to "")
	void*			RelLogIt;		// function pointer to the HcpLogIt
	long			Reserved2;
	long			Reserved3;
};

enum {
HCP_FRMINTRPT_FG_PULS0,
HCP_FRMINTRPT_FG_FVAL,
HCP_FRMINTRPT_FG_MAX,
};

enum {
HCP_GENSYNC_AC_ADU200,
HCP_GENSYNC_AC_NONE,
HCP_GENSYNC_AC_MAX,
};

//////////////////////////////////////////////////////////////////////////////
struct SHwConfig
{
	int				StructSize;		// Initialize to sizeof(SHwConfig)
	int				FrmIntrptSrc;	// This defines frame interrupt source
									// for the FG module - PULS0 is the pulse
									// generator used to generate internal
									// frame starts. FVAL is FrameValid.
	int				GenSyncType;	// This defines how AC handles Generator Sync.
									// ADU200 uses a USB board to interface to
									// generator. NONE implies no AC control
									// over generator. All signal_frame_starts
									// are treated as valid frames.
	int				TimeParam1;
	int*			OffsetPtr;		// used by analog offset calibration
									// otherwise must be NULL
	int				OffsetLen;
	int 			ModeNum;
};

//////////////////////////////////////////////////////////////////////////////
struct SCalCtrl
{
// for future use
	int				StructSize;		// Initialize to sizeof(SCalStats)
};

//////////////////////////////////////////////////////////////////////////////
struct SCalInfo
{
	int				StructSize;		// Initialize to sizeof(SCalStats)
	float			OfstMedian;
	float			OfstStdDev;
	float			GainMedian;
	float			GainStdDev;
	float			GainScaling;
	long			Time;
};

//////////////////////////////////////////////////////////////////////////////
struct SCalLimits
{
	int				StructSize;		// Initialize to sizeof(SCalLimits)
	int				OfstLimitLo;
	int				OfstLimitHi;
	int				GainLimitHi;
};

//////////////////////////////////////////////////////////////////////////////
// use these values in the DataType below
enum {
HCP_CALACQ_OFST, 
HCP_CALACQ_GAIN,
HCP_CALACQ_ANLG, // analog offset
HCP_CALACQ_MAX
};

//////////////////////////////////////////////////////////////////////////////
struct SCalAcqData
{
	int				StructSize;		// Initialize to sizeof(SCalAcqData)
	int				DataType;		// offset, gain, extended gain etc
	int				DataByteSize;	// size of data (int=4; WORD=2)
	int				FrmX;
	int				FrmY;
	void*			Data;
	int				NumFrames;
	int				Reserved1;
	int				Reserved2;
};

//////////////////////////////////////////////////////////////////////////////
struct SCorrectImage
{
	int				StructSize;		// Initialize to sizeof(SCorrectImage)
	WORD*			BufIn;		
	int				BufInX;
	int				BufInY;
	WORD*			BufOut;		
	int				BufOutX;
	int				BufOutY;
	int				CorrType;
	int				Reserved1;
};

//////////////////////////////////////////////////////////////////////////////
struct SAnalogOffsetParams
{
	int				StructSize;	// Initialize to sizeof(SAnalogOffsetParams)
	int				TargetValue;
	int				Tolerance;
	int				MedianPercent;
	float			FracIterDelta;
	int				NumIterations;
};

//////////////////////////////////////////////////////////////////////////////
struct SAnalogOffsetInfo
{
	int				StructSize;	// Initialize to sizeof(SAnalogOffsetInfo)
	int				AsicNum;
	int				AnalogOfstElapsdTime;
	int*			AsicOffsets;
};

//////////////////////////////////////////////////////////////////////////////
struct SCorrections
{
	int				StructSize;	// Initialize to sizeof(SCorrections)
	BOOL			Ofst;
	BOOL			Gain;
	BOOL			Dfct;
	BOOL			Line;
};

//////////////////////////////////////////////////////////////////////////////
struct SGainScaling
{
	int				StructSize;	// Initialize to sizeof(SGainScaling)
	int				GainType;
	int				MaxLinearValue;
	int				PxSatValue;
	int				PxRepValue;
};

//////////////////////////////////////////////////////////////////////////////
struct SModeInfo
{
	int				StructSize;	// Initialize to sizeof(SModeInfo)
	int				ModeNum;
	int				AcqType;	// VIP_ACQ_TYPE_ACCUMULATION etc; note CB adds
	float			FrameRate;
	float			AnalogGain;
	int				LinesPerFrame;
	int				ColsPerFrame;
	int				LinesPerPixel;
	int				ColsPerPixel;
	char			ModeDescription[MAX_STR];
	char			DirReadyModeDescription[MAX_STR];
	int				DcdsEnable;
	float			MxAllowedFrameRate;
	BOOL			UserSync;
	int 			AcqFrmCount;
	int 			CalFrmCount;
	int				GainRoiUpperLeftX;
	int				GainRoiUpperLeftY;
	int				GainRoiLowerRightX;
	int				GainRoiLowerRightY;
	int				UncorrectablePixelRepValue;
	int				OffsetCalShift;			
	int				MaxDefectRange;			
	int				Reserved1;			
	int				Reserved2;			
	int				Reserved3;			
	int				Reserved4;			
	void*			ExtInfoPtr;
	int				ExtInfoLen;
};

//////////////////////////////////////////////////////////////////////////////
struct SSysInfo
{
	int				StructSize;	// Initialize to sizeof(SSysInfo)
	int				NumModes;
	int				DfltModeNum;
	int				MxLinesPerFrame;
	int				MxColsPerFrame;
	int				MxPixelValue;
	BOOL			HasVideo;
	char			SysDescription[MAX_STR];
	int				StartUpConfig;
	int				NumAsics;
	int				ReceptorType;
	int				BorderPixels;
	int				MxImageValue; // normally the same as MxPixelValue			
	int				Reserved1;			
	int				Reserved2;			
	int				Reserved3;			
	int				Reserved4;			
};

//////////////////////////////////////////////////////////////////////////////
struct SSysMode
{
	int				StructSize;	// Initialize to sizeof(SSysMode)
	int				SystemMode;
};

//////////////////////////////////////////////////////////////////////////////
struct SQueryErrorInfo
{
	int				StructSize;	// Initialize to sizeof(SQueryErrorInfo)
	int				ErrorCode;
	char			ErrMsg[MAX_STR];
	char			ActionStr[MAX_STR];
};

//////////////////////////////////////////////////////////////////////////////
struct SQueryProgInfo // uType = HCP_U_QPI
{
	int				StructSize;	// Initialize to sizeof(SQueryProgInfo)
	int				NumFrames;
	BOOL			Complete;
	int				NumPulses;
	BOOL			ReadyForPulse;
};

//////////////////////////////////////////////////////////////////////////////
// for future use
struct SQueryProgInfoEx // uType = HCP_U_QPIX
{
	int				StructSize;	// Initialize to sizeof(SQueryProgInfoEx)
};

//////////////////////////////////////////////////////////////////////////////
// for future use
struct SQueryProgInfoFw // uType = HCP_U_QPIFW
{
	int				StructSize;	// Initialize to sizeof(SQueryProgInfoFw)
	int				ProgressCurrent;
	int				ProgressLimit;
	BOOL			Complete;
};

//////////////////////////////////////////////////////////////////////////////
union  UQueryProgInfo
{
	SQueryProgInfo		qpi;
	SQueryProgInfoEx	qpix;
	SQueryProgInfoFw	qpifw;
};

enum {
HCP_U_QPI,
HCP_U_QPIX,
HCP_U_QPIFW,
HCP_U_QPI_MAX
};

//////////////////////////////////////////////////////////////////////////////
struct SOpenReceptorLink
{
	int				StructSize;	// Initialize to sizeof(SOpenReceptorLink)
	void*			VcpDatPtr;	// Internal Virtual CP use only - must be NULL
	char			RecDirPath[MAX_STR];
	int				TestMode;	// Normally zero - enables frame stamp which 
								// overwrites some pixels
	int				DebugMode;	// May be used to turn on debug verbosity
};

//////////////////////////////////////////////////////////////////////////////
struct SCheckLink
{
	int				StructSize;	// Initialize to sizeof(SOpenReceptorLink)
	int				ImgMedianVal;	// result of check_link - image Median
	float			ImgStdDev;		// result of check_link - image StdDev
	int				ImgMedLoLim;	// lo limit of acceptable median - zero
									// implies 100 default
	int				ImgMedHiLim;	// hi limit of acceptable median - zero
									// implies value derived from receptor 
									// configuration
	float			ImgMedSDRatioLim;	// Acceptable ratio Median / StdDev -
									// zero implies that it must not be below 4
	int				NumImgAcq;		// number of images to acquire - zero is
									// interpreted as 1
	int				Reserved1;
	int				Reserved2;
	int				Reserved3;
	int				Reserved4;
};

//////////////////////////////////////////////////////////////////////////////
enum HcpDllRef {
HCP_DLL_REF_AC,
HCP_DLL_REF_RC,
HCP_DLL_REF_CR,
HCP_DLL_REF_CA,
HCP_DLL_REF_MC,
HCP_DLL_REF_IO,
HCP_DLL_REF_RP,
HCP_DLL_REF_FG,
HCP_DLL_REF_MAX
};

//////////////////////////////////////////////////////////////////////////////
#endif // VIP_INC_SUNDRYSTRUCTS_H
